﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using CSWriter.Blogs;
using CommunityServerRest;

namespace CSWriter {
	public partial class Opciones : Form {

		ServiceCredentials credentials = null;
		public ServiceCredentials ServiceCredentials {
			get { return credentials; }
			set {
				credentials=value;
				if (value != null) {
					username.Text = value.Username;
					apiKey.Text = value.ApiKey;
					serviceUrl.Text = value.ServiceUrl;
				}
			}
		}

		public Opciones() {
			InitializeComponent();
		}

		private void aceptar_Click(object sender, EventArgs e) {
			Close();
		}

		private void Opciones_Closing(object sender, CancelEventArgs e) {
			ServiceCredentials = new ServiceCredentials(serviceUrl.Text, username.Text, apiKey.Text);
			DialogResult = DialogResult.OK;
		}

		private void cancel_Click(object sender, EventArgs e) {
			Close();
		}
	}
}